{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "be56c0e6-0a06-41dd-a552-71d7f9aeba6f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class GenerateResponse in module ollama._types:\n",
      "\n",
      "class GenerateResponse(BaseGenerateResponse)\n",
      " |  GenerateResponse(\n",
      " |      *,\n",
      " |      model: Optional[str] = None,\n",
      " |      created_at: Optional[str] = None,\n",
      " |      done: Optional[bool] = None,\n",
      " |      done_reason: Optional[str] = None,\n",
      " |      total_duration: Optional[int] = None,\n",
      " |      load_duration: Optional[int] = None,\n",
      " |      prompt_eval_count: Optional[int] = None,\n",
      " |      prompt_eval_duration: Optional[int] = None,\n",
      " |      eval_count: Optional[int] = None,\n",
      " |      eval_duration: Optional[int] = None,\n",
      " |      response: str,\n",
      " |      thinking: Optional[str] = None,\n",
      " |      context: Optional[Sequence[int]] = None\n",
      " |  ) -> None\n",
      " |\n",
      " |  Response returned by generate requests.\n",
      " |\n",
      " |  Method resolution order:\n",
      " |      GenerateResponse\n",
      " |      BaseGenerateResponse\n",
      " |      SubscriptableBaseModel\n",
      " |      pydantic.main.BaseModel\n",
      " |      builtins.object\n",
      " |\n",
      " |  Data and other attributes defined here:\n",
      " |\n",
      " |  __abstractmethods__ = frozenset()\n",
      " |\n",
      " |  __annotations__ = {'context': typing.Optional[typing.Sequence[int]], '...\n",
      " |\n",
      " |  __class_vars__ = set()\n",
      " |\n",
      " |  __private_attributes__ = {}\n",
      " |\n",
      " |  __pydantic_complete__ = True\n",
      " |\n",
      " |  __pydantic_computed_fields__ = {}\n",
      " |\n",
      " |  __pydantic_core_schema__ = {'cls': <class 'ollama._types.GenerateRespo...\n",
      " |\n",
      " |  __pydantic_custom_init__ = False\n",
      " |\n",
      " |  __pydantic_decorators__ = DecoratorInfos(validators={}, field_validato...\n",
      " |\n",
      " |  __pydantic_fields__ = {'context': FieldInfo(annotation=Union[Sequence[...\n",
      " |\n",
      " |  __pydantic_generic_metadata__ = {'args': (), 'origin': None, 'paramete...\n",
      " |\n",
      " |  __pydantic_parent_namespace__ = None\n",
      " |\n",
      " |  __pydantic_post_init__ = None\n",
      " |\n",
      " |  __pydantic_serializer__ = SchemaSerializer(serializer=Model(\n",
      " |      Model...\n",
      " |\n",
      " |  __pydantic_setattr_handlers__ = {}\n",
      " |\n",
      " |  __pydantic_validator__ = SchemaValidator(title=\"GenerateResponse\", val...\n",
      " |\n",
      " |  __signature__ = <Signature (*, model: Optional[str] = None, crea...con...\n",
      " |\n",
      " |  model_config = {}\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from SubscriptableBaseModel:\n",
      " |\n",
      " |  __contains__(self, key: str) -> bool\n",
      " |      >>> msg = Message(role='user')\n",
      " |      >>> 'nonexistent' in msg\n",
      " |      False\n",
      " |      >>> 'role' in msg\n",
      " |      True\n",
      " |      >>> 'content' in msg\n",
      " |      False\n",
      " |      >>> msg.content = 'hello!'\n",
      " |      >>> 'content' in msg\n",
      " |      True\n",
      " |      >>> msg = Message(role='user', content='hello!')\n",
      " |      >>> 'content' in msg\n",
      " |      True\n",
      " |      >>> 'tool_calls' in msg\n",
      " |      False\n",
      " |      >>> msg['tool_calls'] = []\n",
      " |      >>> 'tool_calls' in msg\n",
      " |      True\n",
      " |      >>> msg['tool_calls'] = [Message.ToolCall(function=Message.ToolCall.Function(name='foo', arguments={}))]\n",
      " |      >>> 'tool_calls' in msg\n",
      " |      True\n",
      " |      >>> msg['tool_calls'] = None\n",
      " |      >>> 'tool_calls' in msg\n",
      " |      True\n",
      " |      >>> tool = Tool()\n",
      " |      >>> 'type' in tool\n",
      " |      True\n",
      " |\n",
      " |  __getitem__(self, key: str) -> Any\n",
      " |      >>> msg = Message(role='user')\n",
      " |      >>> msg['role']\n",
      " |      'user'\n",
      " |      >>> msg = Message(role='user')\n",
      " |      >>> msg['nonexistent']\n",
      " |      Traceback (most recent call last):\n",
      " |      KeyError: 'nonexistent'\n",
      " |\n",
      " |  __setitem__(self, key: str, value: Any) -> None\n",
      " |      >>> msg = Message(role='user')\n",
      " |      >>> msg['role'] = 'assistant'\n",
      " |      >>> msg['role']\n",
      " |      'assistant'\n",
      " |      >>> tool_call = Message.ToolCall(function=Message.ToolCall.Function(name='foo', arguments={}))\n",
      " |      >>> msg = Message(role='user', content='hello')\n",
      " |      >>> msg['tool_calls'] = [tool_call]\n",
      " |      >>> msg['tool_calls'][0]['function']['name']\n",
      " |      'foo'\n",
      " |\n",
      " |  get(self, key: str, default: Any = None) -> Any\n",
      " |      >>> msg = Message(role='user')\n",
      " |      >>> msg.get('role')\n",
      " |      'user'\n",
      " |      >>> msg = Message(role='user')\n",
      " |      >>> msg.get('nonexistent')\n",
      " |      >>> msg = Message(role='user')\n",
      " |      >>> msg.get('nonexistent', 'default')\n",
      " |      'default'\n",
      " |      >>> msg = Message(role='user', tool_calls=[ Message.ToolCall(function=Message.ToolCall.Function(name='foo', arguments={}))])\n",
      " |      >>> msg.get('tool_calls')[0]['function']['name']\n",
      " |      'foo'\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from SubscriptableBaseModel:\n",
      " |\n",
      " |  __weakref__\n",
      " |      list of weak references to the object\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from pydantic.main.BaseModel:\n",
      " |\n",
      " |  __copy__(self) -> 'Self'\n",
      " |      Returns a shallow copy of the model.\n",
      " |\n",
      " |  __deepcopy__(self, memo: 'dict[int, Any] | None' = None) -> 'Self'\n",
      " |      Returns a deep copy of the model.\n",
      " |\n",
      " |  __delattr__(self, item: 'str') -> 'Any'\n",
      " |      Implement delattr(self, name).\n",
      " |\n",
      " |  __eq__(self, other: 'Any') -> 'bool'\n",
      " |      Return self==value.\n",
      " |\n",
      " |  __getattr__(self, item: 'str') -> 'Any'\n",
      " |\n",
      " |  __getstate__(self) -> 'dict[Any, Any]'\n",
      " |      Helper for pickle.\n",
      " |\n",
      " |  __init__(self, /, **data: 'Any') -> 'None'\n",
      " |      Create a new model by parsing and validating input data from keyword arguments.\n",
      " |\n",
      " |      Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be\n",
      " |      validated to form a valid model.\n",
      " |\n",
      " |      `self` is explicitly positional-only to allow `self` as a field name.\n",
      " |\n",
      " |  __iter__(self) -> 'TupleGenerator'\n",
      " |      So `dict(model)` works.\n",
      " |\n",
      " |  __pretty__(self, fmt: 'typing.Callable[[Any], Any]', **kwargs: 'Any') -> 'typing.Generator[Any, None, None]' from pydantic._internal._repr.Representation\n",
      " |      Used by devtools (https://python-devtools.helpmanual.io/) to pretty print objects.\n",
      " |\n",
      " |  __replace__(self, **changes: 'Any') -> 'Self'\n",
      " |      # Because we make use of `@dataclass_transform()`, `__replace__` is already synthesized by\n",
      " |      # type checkers, so we define the implementation in this `if not TYPE_CHECKING:` block:\n",
      " |\n",
      " |  __repr__(self) -> 'str'\n",
      " |      Return repr(self).\n",
      " |\n",
      " |  __repr_args__(self) -> '_repr.ReprArgs'\n",
      " |\n",
      " |  __repr_name__(self) -> 'str' from pydantic._internal._repr.Representation\n",
      " |      Name of the instance's class, used in __repr__.\n",
      " |\n",
      " |  __repr_recursion__(self, object: 'Any') -> 'str' from pydantic._internal._repr.Representation\n",
      " |      Returns the string representation of a recursive object.\n",
      " |\n",
      " |  __repr_str__(self, join_str: 'str') -> 'str' from pydantic._internal._repr.Representation\n",
      " |\n",
      " |  __rich_repr__(self) -> 'RichReprResult' from pydantic._internal._repr.Representation\n",
      " |      Used by Rich (https://rich.readthedocs.io/en/stable/pretty.html) to pretty print objects.\n",
      " |\n",
      " |  __setattr__(self, name: 'str', value: 'Any') -> 'None'\n",
      " |      Implement setattr(self, name, value).\n",
      " |\n",
      " |  __setstate__(self, state: 'dict[Any, Any]') -> 'None'\n",
      " |\n",
      " |  __str__(self) -> 'str'\n",
      " |      Return str(self).\n",
      " |\n",
      " |  copy(\n",
      " |      self,\n",
      " |      *,\n",
      " |      include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,\n",
      " |      exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,\n",
      " |      update: 'Dict[str, Any] | None' = None,\n",
      " |      deep: 'bool' = False\n",
      " |  ) -> 'Self'\n",
      " |      Returns a copy of the model.\n",
      " |\n",
      " |      !!! warning \"Deprecated\"\n",
      " |          This method is now deprecated; use `model_copy` instead.\n",
      " |\n",
      " |      If you need `include` or `exclude`, use:\n",
      " |\n",
      " |      ```python {test=\"skip\" lint=\"skip\"}\n",
      " |      data = self.model_dump(include=include, exclude=exclude, round_trip=True)\n",
      " |      data = {**data, **(update or {})}\n",
      " |      copied = self.model_validate(data)\n",
      " |      ```\n",
      " |\n",
      " |      Args:\n",
      " |          include: Optional set or mapping specifying which fields to include in the copied model.\n",
      " |          exclude: Optional set or mapping specifying which fields to exclude in the copied model.\n",
      " |          update: Optional dictionary of field-value pairs to override field values in the copied model.\n",
      " |          deep: If True, the values of fields that are Pydantic models will be deep-copied.\n",
      " |\n",
      " |      Returns:\n",
      " |          A copy of the model with included, excluded and updated fields as specified.\n",
      " |\n",
      " |  dict(\n",
      " |      self,\n",
      " |      *,\n",
      " |      include: 'IncEx | None' = None,\n",
      " |      exclude: 'IncEx | None' = None,\n",
      " |      by_alias: 'bool' = False,\n",
      " |      exclude_unset: 'bool' = False,\n",
      " |      exclude_defaults: 'bool' = False,\n",
      " |      exclude_none: 'bool' = False\n",
      " |  ) -> 'Dict[str, Any]'\n",
      " |\n",
      " |  json(\n",
      " |      self,\n",
      " |      *,\n",
      " |      include: 'IncEx | None' = None,\n",
      " |      exclude: 'IncEx | None' = None,\n",
      " |      by_alias: 'bool' = False,\n",
      " |      exclude_unset: 'bool' = False,\n",
      " |      exclude_defaults: 'bool' = False,\n",
      " |      exclude_none: 'bool' = False,\n",
      " |      encoder: 'Callable[[Any], Any] | None' = PydanticUndefined,\n",
      " |      models_as_dict: 'bool' = PydanticUndefined,\n",
      " |      **dumps_kwargs: 'Any'\n",
      " |  ) -> 'str'\n",
      " |\n",
      " |  model_copy(\n",
      " |      self,\n",
      " |      *,\n",
      " |      update: 'Mapping[str, Any] | None' = None,\n",
      " |      deep: 'bool' = False\n",
      " |  ) -> 'Self'\n",
      " |      !!! abstract \"Usage Documentation\"\n",
      " |          [`model_copy`](../concepts/serialization.md#model_copy)\n",
      " |\n",
      " |      Returns a copy of the model.\n",
      " |\n",
      " |      !!! note\n",
      " |          The underlying instance's [`__dict__`][object.__dict__] attribute is copied. This\n",
      " |          might have unexpected side effects if you store anything in it, on top of the model\n",
      " |          fields (e.g. the value of [cached properties][functools.cached_property]).\n",
      " |\n",
      " |      Args:\n",
      " |          update: Values to change/add in the new model. Note: the data is not validated\n",
      " |              before creating the new model. You should trust this data.\n",
      " |          deep: Set to `True` to make a deep copy of the model.\n",
      " |\n",
      " |      Returns:\n",
      " |          New model instance.\n",
      " |\n",
      " |  model_dump(\n",
      " |      self,\n",
      " |      *,\n",
      " |      mode: \"Literal['json', 'python'] | str\" = 'python',\n",
      " |      include: 'IncEx | None' = None,\n",
      " |      exclude: 'IncEx | None' = None,\n",
      " |      context: 'Any | None' = None,\n",
      " |      by_alias: 'bool | None' = None,\n",
      " |      exclude_unset: 'bool' = False,\n",
      " |      exclude_defaults: 'bool' = False,\n",
      " |      exclude_none: 'bool' = False,\n",
      " |      round_trip: 'bool' = False,\n",
      " |      warnings: \"bool | Literal['none', 'warn', 'error']\" = True,\n",
      " |      fallback: 'Callable[[Any], Any] | None' = None,\n",
      " |      serialize_as_any: 'bool' = False\n",
      " |  ) -> 'dict[str, Any]'\n",
      " |      !!! abstract \"Usage Documentation\"\n",
      " |          [`model_dump`](../concepts/serialization.md#modelmodel_dump)\n",
      " |\n",
      " |      Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.\n",
      " |\n",
      " |      Args:\n",
      " |          mode: The mode in which `to_python` should run.\n",
      " |              If mode is 'json', the output will only contain JSON serializable types.\n",
      " |              If mode is 'python', the output may contain non-JSON-serializable Python objects.\n",
      " |          include: A set of fields to include in the output.\n",
      " |          exclude: A set of fields to exclude from the output.\n",
      " |          context: Additional context to pass to the serializer.\n",
      " |          by_alias: Whether to use the field's alias in the dictionary key if defined.\n",
      " |          exclude_unset: Whether to exclude fields that have not been explicitly set.\n",
      " |          exclude_defaults: Whether to exclude fields that are set to their default value.\n",
      " |          exclude_none: Whether to exclude fields that have a value of `None`.\n",
      " |          round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].\n",
      " |          warnings: How to handle serialization errors. False/\"none\" ignores them, True/\"warn\" logs errors,\n",
      " |              \"error\" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError].\n",
      " |          fallback: A function to call when an unknown value is encountered. If not provided,\n",
      " |              a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.\n",
      " |          serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.\n",
      " |\n",
      " |      Returns:\n",
      " |          A dictionary representation of the model.\n",
      " |\n",
      " |  model_dump_json(\n",
      " |      self,\n",
      " |      *,\n",
      " |      indent: 'int | None' = None,\n",
      " |      include: 'IncEx | None' = None,\n",
      " |      exclude: 'IncEx | None' = None,\n",
      " |      context: 'Any | None' = None,\n",
      " |      by_alias: 'bool | None' = None,\n",
      " |      exclude_unset: 'bool' = False,\n",
      " |      exclude_defaults: 'bool' = False,\n",
      " |      exclude_none: 'bool' = False,\n",
      " |      round_trip: 'bool' = False,\n",
      " |      warnings: \"bool | Literal['none', 'warn', 'error']\" = True,\n",
      " |      fallback: 'Callable[[Any], Any] | None' = None,\n",
      " |      serialize_as_any: 'bool' = False\n",
      " |  ) -> 'str'\n",
      " |      !!! abstract \"Usage Documentation\"\n",
      " |          [`model_dump_json`](../concepts/serialization.md#modelmodel_dump_json)\n",
      " |\n",
      " |      Generates a JSON representation of the model using Pydantic's `to_json` method.\n",
      " |\n",
      " |      Args:\n",
      " |          indent: Indentation to use in the JSON output. If None is passed, the output will be compact.\n",
      " |          include: Field(s) to include in the JSON output.\n",
      " |          exclude: Field(s) to exclude from the JSON output.\n",
      " |          context: Additional context to pass to the serializer.\n",
      " |          by_alias: Whether to serialize using field aliases.\n",
      " |          exclude_unset: Whether to exclude fields that have not been explicitly set.\n",
      " |          exclude_defaults: Whether to exclude fields that are set to their default value.\n",
      " |          exclude_none: Whether to exclude fields that have a value of `None`.\n",
      " |          round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].\n",
      " |          warnings: How to handle serialization errors. False/\"none\" ignores them, True/\"warn\" logs errors,\n",
      " |              \"error\" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError].\n",
      " |          fallback: A function to call when an unknown value is encountered. If not provided,\n",
      " |              a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.\n",
      " |          serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.\n",
      " |\n",
      " |      Returns:\n",
      " |          A JSON string representation of the model.\n",
      " |\n",
      " |  model_post_init(self, context: 'Any', /) -> 'None'\n",
      " |      Override this method to perform additional initialization after `__init__` and `model_construct`.\n",
      " |      This is useful if you want to do some validation that requires the entire model to be initialized.\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from pydantic.main.BaseModel:\n",
      " |\n",
      " |  __class_getitem__(typevar_values: 'type[Any] | tuple[type[Any], ...]') -> 'type[BaseModel] | _forward_ref.PydanticRecursiveRef'\n",
      " |\n",
      " |  __get_pydantic_core_schema__(\n",
      " |      source: 'type[BaseModel]',\n",
      " |      handler: 'GetCoreSchemaHandler',\n",
      " |      /\n",
      " |  ) -> 'CoreSchema'\n",
      " |\n",
      " |  __get_pydantic_json_schema__(\n",
      " |      core_schema: 'CoreSchema',\n",
      " |      handler: 'GetJsonSchemaHandler',\n",
      " |      /\n",
      " |  ) -> 'JsonSchemaValue'\n",
      " |      Hook into generating the model's JSON schema.\n",
      " |\n",
      " |      Args:\n",
      " |          core_schema: A `pydantic-core` CoreSchema.\n",
      " |              You can ignore this argument and call the handler with a new CoreSchema,\n",
      " |              wrap this CoreSchema (`{'type': 'nullable', 'schema': current_schema}`),\n",
      " |              or just call the handler with the original schema.\n",
      " |          handler: Call into Pydantic's internal JSON schema generation.\n",
      " |              This will raise a `pydantic.errors.PydanticInvalidForJsonSchema` if JSON schema\n",
      " |              generation fails.\n",
      " |              Since this gets called by `BaseModel.model_json_schema` you can override the\n",
      " |              `schema_generator` argument to that function to change JSON schema generation globally\n",
      " |              for a type.\n",
      " |\n",
      " |      Returns:\n",
      " |          A JSON schema, as a Python object.\n",
      " |\n",
      " |  __pydantic_init_subclass__(**kwargs: 'Any') -> 'None'\n",
      " |      This is intended to behave just like `__init_subclass__`, but is called by `ModelMetaclass`\n",
      " |      only after the class is actually fully initialized. In particular, attributes like `model_fields` will\n",
      " |      be present when this is called.\n",
      " |\n",
      " |      This is necessary because `__init_subclass__` will always be called by `type.__new__`,\n",
      " |      and it would require a prohibitively large refactor to the `ModelMetaclass` to ensure that\n",
      " |      `type.__new__` was called in such a manner that the class would already be sufficiently initialized.\n",
      " |\n",
      " |      This will receive the same `kwargs` that would be passed to the standard `__init_subclass__`, namely,\n",
      " |      any kwargs passed to the class definition that aren't used internally by pydantic.\n",
      " |\n",
      " |      Args:\n",
      " |          **kwargs: Any keyword arguments passed to the class definition that aren't used internally\n",
      " |              by pydantic.\n",
      " |\n",
      " |  construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'\n",
      " |\n",
      " |  from_orm(obj: 'Any') -> 'Self'\n",
      " |\n",
      " |  model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'\n",
      " |      Creates a new instance of the `Model` class with validated data.\n",
      " |\n",
      " |      Creates a new model setting `__dict__` and `__pydantic_fields_set__` from trusted or pre-validated data.\n",
      " |      Default values are respected, but no other validation is performed.\n",
      " |\n",
      " |      !!! note\n",
      " |          `model_construct()` generally respects the `model_config.extra` setting on the provided model.\n",
      " |          That is, if `model_config.extra == 'allow'`, then all extra passed values are added to the model instance's `__dict__`\n",
      " |          and `__pydantic_extra__` fields. If `model_config.extra == 'ignore'` (the default), then all extra passed values are ignored.\n",
      " |          Because no validation is performed with a call to `model_construct()`, having `model_config.extra == 'forbid'` does not result in\n",
      " |          an error if extra values are passed, but they will be ignored.\n",
      " |\n",
      " |      Args:\n",
      " |          _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,\n",
      " |              this is directly used for the [`model_fields_set`][pydantic.BaseModel.model_fields_set] attribute.\n",
      " |              Otherwise, the field names from the `values` argument will be used.\n",
      " |          values: Trusted or pre-validated data dictionary.\n",
      " |\n",
      " |      Returns:\n",
      " |          A new instance of the `Model` class with validated data.\n",
      " |\n",
      " |  model_json_schema(\n",
      " |      by_alias: 'bool' = True,\n",
      " |      ref_template: 'str' = '#/$defs/{model}',\n",
      " |      schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,\n",
      " |      mode: 'JsonSchemaMode' = 'validation'\n",
      " |  ) -> 'dict[str, Any]'\n",
      " |      Generates a JSON schema for a model class.\n",
      " |\n",
      " |      Args:\n",
      " |          by_alias: Whether to use attribute aliases or not.\n",
      " |          ref_template: The reference template.\n",
      " |          schema_generator: To override the logic used to generate the JSON schema, as a subclass of\n",
      " |              `GenerateJsonSchema` with your desired modifications\n",
      " |          mode: The mode in which to generate the schema.\n",
      " |\n",
      " |      Returns:\n",
      " |          The JSON schema for the given model class.\n",
      " |\n",
      " |  model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'\n",
      " |      Compute the class name for parametrizations of generic classes.\n",
      " |\n",
      " |      This method can be overridden to achieve a custom naming scheme for generic BaseModels.\n",
      " |\n",
      " |      Args:\n",
      " |          params: Tuple of types of the class. Given a generic class\n",
      " |              `Model` with 2 type variables and a concrete model `Model[str, int]`,\n",
      " |              the value `(str, int)` would be passed to `params`.\n",
      " |\n",
      " |      Returns:\n",
      " |          String representing the new class where `params` are passed to `cls` as type variables.\n",
      " |\n",
      " |      Raises:\n",
      " |          TypeError: Raised when trying to generate concrete names for non-generic models.\n",
      " |\n",
      " |  model_rebuild(\n",
      " |      *,\n",
      " |      force: 'bool' = False,\n",
      " |      raise_errors: 'bool' = True,\n",
      " |      _parent_namespace_depth: 'int' = 2,\n",
      " |      _types_namespace: 'MappingNamespace | None' = None\n",
      " |  ) -> 'bool | None'\n",
      " |      Try to rebuild the pydantic-core schema for the model.\n",
      " |\n",
      " |      This may be necessary when one of the annotations is a ForwardRef which could not be resolved during\n",
      " |      the initial attempt to build the schema, and automatic rebuilding fails.\n",
      " |\n",
      " |      Args:\n",
      " |          force: Whether to force the rebuilding of the model schema, defaults to `False`.\n",
      " |          raise_errors: Whether to raise errors, defaults to `True`.\n",
      " |          _parent_namespace_depth: The depth level of the parent namespace, defaults to 2.\n",
      " |          _types_namespace: The types namespace, defaults to `None`.\n",
      " |\n",
      " |      Returns:\n",
      " |          Returns `None` if the schema is already \"complete\" and rebuilding was not required.\n",
      " |          If rebuilding _was_ required, returns `True` if rebuilding was successful, otherwise `False`.\n",
      " |\n",
      " |  model_validate(\n",
      " |      obj: 'Any',\n",
      " |      *,\n",
      " |      strict: 'bool | None' = None,\n",
      " |      from_attributes: 'bool | None' = None,\n",
      " |      context: 'Any | None' = None,\n",
      " |      by_alias: 'bool | None' = None,\n",
      " |      by_name: 'bool | None' = None\n",
      " |  ) -> 'Self'\n",
      " |      Validate a pydantic model instance.\n",
      " |\n",
      " |      Args:\n",
      " |          obj: The object to validate.\n",
      " |          strict: Whether to enforce types strictly.\n",
      " |          from_attributes: Whether to extract data from object attributes.\n",
      " |          context: Additional context to pass to the validator.\n",
      " |          by_alias: Whether to use the field's alias when validating against the provided input data.\n",
      " |          by_name: Whether to use the field's name when validating against the provided input data.\n",
      " |\n",
      " |      Raises:\n",
      " |          ValidationError: If the object could not be validated.\n",
      " |\n",
      " |      Returns:\n",
      " |          The validated model instance.\n",
      " |\n",
      " |  model_validate_json(\n",
      " |      json_data: 'str | bytes | bytearray',\n",
      " |      *,\n",
      " |      strict: 'bool | None' = None,\n",
      " |      context: 'Any | None' = None,\n",
      " |      by_alias: 'bool | None' = None,\n",
      " |      by_name: 'bool | None' = None\n",
      " |  ) -> 'Self'\n",
      " |      !!! abstract \"Usage Documentation\"\n",
      " |          [JSON Parsing](../concepts/json.md#json-parsing)\n",
      " |\n",
      " |      Validate the given JSON data against the Pydantic model.\n",
      " |\n",
      " |      Args:\n",
      " |          json_data: The JSON data to validate.\n",
      " |          strict: Whether to enforce types strictly.\n",
      " |          context: Extra variables to pass to the validator.\n",
      " |          by_alias: Whether to use the field's alias when validating against the provided input data.\n",
      " |          by_name: Whether to use the field's name when validating against the provided input data.\n",
      " |\n",
      " |      Returns:\n",
      " |          The validated Pydantic model.\n",
      " |\n",
      " |      Raises:\n",
      " |          ValidationError: If `json_data` is not a JSON string or the object could not be validated.\n",
      " |\n",
      " |  model_validate_strings(\n",
      " |      obj: 'Any',\n",
      " |      *,\n",
      " |      strict: 'bool | None' = None,\n",
      " |      context: 'Any | None' = None,\n",
      " |      by_alias: 'bool | None' = None,\n",
      " |      by_name: 'bool | None' = None\n",
      " |  ) -> 'Self'\n",
      " |      Validate the given object with string data against the Pydantic model.\n",
      " |\n",
      " |      Args:\n",
      " |          obj: The object containing string data to validate.\n",
      " |          strict: Whether to enforce types strictly.\n",
      " |          context: Extra variables to pass to the validator.\n",
      " |          by_alias: Whether to use the field's alias when validating against the provided input data.\n",
      " |          by_name: Whether to use the field's name when validating against the provided input data.\n",
      " |\n",
      " |      Returns:\n",
      " |          The validated Pydantic model.\n",
      " |\n",
      " |  parse_file(\n",
      " |      path: 'str | Path',\n",
      " |      *,\n",
      " |      content_type: 'str | None' = None,\n",
      " |      encoding: 'str' = 'utf8',\n",
      " |      proto: 'DeprecatedParseProtocol | None' = None,\n",
      " |      allow_pickle: 'bool' = False\n",
      " |  ) -> 'Self'\n",
      " |\n",
      " |  parse_obj(obj: 'Any') -> 'Self'\n",
      " |\n",
      " |  parse_raw(\n",
      " |      b: 'str | bytes',\n",
      " |      *,\n",
      " |      content_type: 'str | None' = None,\n",
      " |      encoding: 'str' = 'utf8',\n",
      " |      proto: 'DeprecatedParseProtocol | None' = None,\n",
      " |      allow_pickle: 'bool' = False\n",
      " |  ) -> 'Self'\n",
      " |\n",
      " |  schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'\n",
      " |\n",
      " |  schema_json(\n",
      " |      *,\n",
      " |      by_alias: 'bool' = True,\n",
      " |      ref_template: 'str' = '#/$defs/{model}',\n",
      " |      **dumps_kwargs: 'Any'\n",
      " |  ) -> 'str'\n",
      " |\n",
      " |  update_forward_refs(**localns: 'Any') -> 'None'\n",
      " |\n",
      " |  validate(value: 'Any') -> 'Self'\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from pydantic.main.BaseModel:\n",
      " |\n",
      " |  __fields_set__\n",
      " |\n",
      " |  model_extra\n",
      " |      Get extra fields set during validation.\n",
      " |\n",
      " |      Returns:\n",
      " |          A dictionary of extra fields, or `None` if `config.extra` is not set to `\"allow\"`.\n",
      " |\n",
      " |  model_fields_set\n",
      " |      Returns the set of fields that have been explicitly set on this model instance.\n",
      " |\n",
      " |      Returns:\n",
      " |          A set of strings representing the fields that have been set,\n",
      " |              i.e. that were not filled from defaults.\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from pydantic.main.BaseModel:\n",
      " |\n",
      " |  __dict__\n",
      " |      dictionary for instance variables\n",
      " |\n",
      " |  __pydantic_extra__\n",
      " |\n",
      " |  __pydantic_fields_set__\n",
      " |\n",
      " |  __pydantic_private__\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from pydantic.main.BaseModel:\n",
      " |\n",
      " |  __hash__ = None\n",
      " |\n",
      " |  __pydantic_root_model__ = False\n",
      " |\n",
      " |  model_computed_fields = {}\n",
      " |\n",
      " |  model_fields = {'context': FieldInfo(annotation=Union[Sequence[int], N...\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import ollama\n",
    "help(ollama.GenerateResponse)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "afc18c04-5b57-4cba-bee6-b43fb1e768e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['AsyncClient',\n",
       " 'ChatResponse',\n",
       " 'Client',\n",
       " 'EmbedResponse',\n",
       " 'EmbeddingsResponse',\n",
       " 'GenerateResponse',\n",
       " 'Image',\n",
       " 'ListResponse',\n",
       " 'Message',\n",
       " 'Options',\n",
       " 'ProcessResponse',\n",
       " 'ProgressResponse',\n",
       " 'RequestError',\n",
       " 'ResponseError',\n",
       " 'ShowResponse',\n",
       " 'StatusResponse',\n",
       " 'Tool',\n",
       " '__all__',\n",
       " '__builtins__',\n",
       " '__cached__',\n",
       " '__doc__',\n",
       " '__file__',\n",
       " '__loader__',\n",
       " '__name__',\n",
       " '__package__',\n",
       " '__path__',\n",
       " '__spec__',\n",
       " '_client',\n",
       " '_types',\n",
       " '_utils',\n",
       " 'chat',\n",
       " 'copy',\n",
       " 'create',\n",
       " 'delete',\n",
       " 'embed',\n",
       " 'embeddings',\n",
       " 'generate',\n",
       " 'list',\n",
       " 'ps',\n",
       " 'pull',\n",
       " 'push',\n",
       " 'show']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir(ollama)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6035c230-727f-40e9-b502-ee9590d0b84f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class OpenAI in module openai:\n",
      "\n",
      "class OpenAI(openai._base_client.SyncAPIClient)\n",
      " |  OpenAI(\n",
      " |      *,\n",
      " |      api_key: 'str | None' = None,\n",
      " |      organization: 'str | None' = None,\n",
      " |      project: 'str | None' = None,\n",
      " |      base_url: 'str | httpx.URL | None' = None,\n",
      " |      websocket_base_url: 'str | httpx.URL | None' = None,\n",
      " |      timeout: 'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN,\n",
      " |      max_retries: 'int' = 2,\n",
      " |      default_headers: 'Mapping[str, str] | None' = None,\n",
      " |      default_query: 'Mapping[str, object] | None' = None,\n",
      " |      http_client: 'httpx.Client | None' = None,\n",
      " |      _strict_response_validation: 'bool' = False\n",
      " |  ) -> 'None'\n",
      " |\n",
      " |  Method resolution order:\n",
      " |      OpenAI\n",
      " |      openai._base_client.SyncAPIClient\n",
      " |      openai._base_client.BaseClient\n",
      " |      typing.Generic\n",
      " |      builtins.object\n",
      " |\n",
      " |  Methods defined here:\n",
      " |\n",
      " |  __init__(\n",
      " |      self,\n",
      " |      *,\n",
      " |      api_key: 'str | None' = None,\n",
      " |      organization: 'str | None' = None,\n",
      " |      project: 'str | None' = None,\n",
      " |      base_url: 'str | httpx.URL | None' = None,\n",
      " |      websocket_base_url: 'str | httpx.URL | None' = None,\n",
      " |      timeout: 'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN,\n",
      " |      max_retries: 'int' = 2,\n",
      " |      default_headers: 'Mapping[str, str] | None' = None,\n",
      " |      default_query: 'Mapping[str, object] | None' = None,\n",
      " |      http_client: 'httpx.Client | None' = None,\n",
      " |      _strict_response_validation: 'bool' = False\n",
      " |  ) -> 'None' from openai._client.OpenAI\n",
      " |      Construct a new synchronous OpenAI client instance.\n",
      " |\n",
      " |      This automatically infers the following arguments from their corresponding environment variables if they are not provided:\n",
      " |      - `api_key` from `OPENAI_API_KEY`\n",
      " |      - `organization` from `OPENAI_ORG_ID`\n",
      " |      - `project` from `OPENAI_PROJECT_ID`\n",
      " |\n",
      " |  audio = <functools.cached_property object>\n",
      " |  batches = <functools.cached_property object>\n",
      " |  beta = <functools.cached_property object>\n",
      " |  chat = <functools.cached_property object>\n",
      " |  completions = <functools.cached_property object>\n",
      " |  containers = <functools.cached_property object>\n",
      " |  copy(\n",
      " |      self,\n",
      " |      *,\n",
      " |      api_key: 'str | None' = None,\n",
      " |      organization: 'str | None' = None,\n",
      " |      project: 'str | None' = None,\n",
      " |      websocket_base_url: 'str | httpx.URL | None' = None,\n",
      " |      base_url: 'str | httpx.URL | None' = None,\n",
      " |      timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN,\n",
      " |      http_client: 'httpx.Client | None' = None,\n",
      " |      max_retries: 'int | NotGiven' = NOT_GIVEN,\n",
      " |      default_headers: 'Mapping[str, str] | None' = None,\n",
      " |      set_default_headers: 'Mapping[str, str] | None' = None,\n",
      " |      default_query: 'Mapping[str, object] | None' = None,\n",
      " |      set_default_query: 'Mapping[str, object] | None' = None,\n",
      " |      _extra_kwargs: 'Mapping[str, Any]' = {}\n",
      " |  ) -> 'Self' from openai._client.OpenAI\n",
      " |      Create a new client instance re-using the same options given to the current client with optional overriding.\n",
      " |\n",
      " |  embeddings = <functools.cached_property object>\n",
      " |  evals = <functools.cached_property object>\n",
      " |  files = <functools.cached_property object>\n",
      " |  fine_tuning = <functools.cached_property object>\n",
      " |  images = <functools.cached_property object>\n",
      " |  models = <functools.cached_property object>\n",
      " |  moderations = <functools.cached_property object>\n",
      " |  responses = <functools.cached_property object>\n",
      " |  uploads = <functools.cached_property object>\n",
      " |  vector_stores = <functools.cached_property object>\n",
      " |  with_options = copy(\n",
      " |      self,\n",
      " |      *,\n",
      " |      api_key: 'str | None' = None,\n",
      " |      organization: 'str | None' = None,\n",
      " |      project: 'str | None' = None,\n",
      " |      websocket_base_url: 'str | httpx.URL | None' = None,\n",
      " |      base_url: 'str | httpx.URL | None' = None,\n",
      " |      timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN,\n",
      " |      http_client: 'httpx.Client | None' = None,\n",
      " |      max_retries: 'int | NotGiven' = NOT_GIVEN,\n",
      " |      default_headers: 'Mapping[str, str] | None' = None,\n",
      " |      set_default_headers: 'Mapping[str, str] | None' = None,\n",
      " |      default_query: 'Mapping[str, object] | None' = None,\n",
      " |      set_default_query: 'Mapping[str, object] | None' = None,\n",
      " |      _extra_kwargs: 'Mapping[str, Any]' = {}\n",
      " |  ) -> 'Self'\n",
      " |\n",
      " |  with_raw_response = <functools.cached_property object>\n",
      " |  with_streaming_response = <functools.cached_property object>\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties defined here:\n",
      " |\n",
      " |  auth_headers\n",
      " |\n",
      " |  default_headers\n",
      " |\n",
      " |  qs\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes defined here:\n",
      " |\n",
      " |  __annotations__ = {'api_key': 'str', 'organization': 'str | None', 'pr...\n",
      " |\n",
      " |  __parameters__ = ()\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from openai._base_client.SyncAPIClient:\n",
      " |\n",
      " |  __enter__(self: '_T') -> '_T'\n",
      " |\n",
      " |  __exit__(\n",
      " |      self,\n",
      " |      exc_type: 'type[BaseException] | None',\n",
      " |      exc: 'BaseException | None',\n",
      " |      exc_tb: 'TracebackType | None'\n",
      " |  ) -> 'None'\n",
      " |\n",
      " |  close(self) -> 'None'\n",
      " |      Close the underlying HTTPX client.\n",
      " |\n",
      " |      The client will *not* be usable after this.\n",
      " |\n",
      " |  delete(\n",
      " |      self,\n",
      " |      path: 'str',\n",
      " |      *,\n",
      " |      cast_to: 'Type[ResponseT]',\n",
      " |      body: 'Body | None' = None,\n",
      " |      options: 'RequestOptions' = {}\n",
      " |  ) -> 'ResponseT'\n",
      " |\n",
      " |  get(\n",
      " |      self,\n",
      " |      path: 'str',\n",
      " |      *,\n",
      " |      cast_to: 'Type[ResponseT]',\n",
      " |      options: 'RequestOptions' = {},\n",
      " |      stream: 'bool' = False,\n",
      " |      stream_cls: 'type[_StreamT] | None' = None\n",
      " |  ) -> 'ResponseT | _StreamT'\n",
      " |\n",
      " |  get_api_list(\n",
      " |      self,\n",
      " |      path: 'str',\n",
      " |      *,\n",
      " |      model: 'Type[object]',\n",
      " |      page: 'Type[SyncPageT]',\n",
      " |      body: 'Body | None' = None,\n",
      " |      options: 'RequestOptions' = {},\n",
      " |      method: 'str' = 'get'\n",
      " |  ) -> 'SyncPageT'\n",
      " |\n",
      " |  is_closed(self) -> 'bool'\n",
      " |\n",
      " |  patch(\n",
      " |      self,\n",
      " |      path: 'str',\n",
      " |      *,\n",
      " |      cast_to: 'Type[ResponseT]',\n",
      " |      body: 'Body | None' = None,\n",
      " |      options: 'RequestOptions' = {}\n",
      " |  ) -> 'ResponseT'\n",
      " |\n",
      " |  post(\n",
      " |      self,\n",
      " |      path: 'str',\n",
      " |      *,\n",
      " |      cast_to: 'Type[ResponseT]',\n",
      " |      body: 'Body | None' = None,\n",
      " |      options: 'RequestOptions' = {},\n",
      " |      files: 'RequestFiles | None' = None,\n",
      " |      stream: 'bool' = False,\n",
      " |      stream_cls: 'type[_StreamT] | None' = None\n",
      " |  ) -> 'ResponseT | _StreamT'\n",
      " |\n",
      " |  put(\n",
      " |      self,\n",
      " |      path: 'str',\n",
      " |      *,\n",
      " |      cast_to: 'Type[ResponseT]',\n",
      " |      body: 'Body | None' = None,\n",
      " |      files: 'RequestFiles | None' = None,\n",
      " |      options: 'RequestOptions' = {}\n",
      " |  ) -> 'ResponseT'\n",
      " |\n",
      " |  request(\n",
      " |      self,\n",
      " |      cast_to: 'Type[ResponseT]',\n",
      " |      options: 'FinalRequestOptions',\n",
      " |      *,\n",
      " |      stream: 'bool' = False,\n",
      " |      stream_cls: 'type[_StreamT] | None' = None\n",
      " |  ) -> 'ResponseT | _StreamT'\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from openai._base_client.SyncAPIClient:\n",
      " |\n",
      " |  __orig_bases__ = (openai._base_client.BaseClient[httpx.Client, openai....\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from openai._base_client.BaseClient:\n",
      " |\n",
      " |  platform_headers(self) -> 'Dict[str, str]'\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from openai._base_client.BaseClient:\n",
      " |\n",
      " |  custom_auth\n",
      " |\n",
      " |  default_query\n",
      " |\n",
      " |  user_agent\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from openai._base_client.BaseClient:\n",
      " |\n",
      " |  __dict__\n",
      " |      dictionary for instance variables\n",
      " |\n",
      " |  __weakref__\n",
      " |      list of weak references to the object\n",
      " |\n",
      " |  base_url\n",
      " |\n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from typing.Generic:\n",
      " |\n",
      " |  __class_getitem__(...)\n",
      " |      Parameterizes a generic class.\n",
      " |\n",
      " |      At least, parameterizing a generic class is the *main* thing this\n",
      " |      method does. For example, for some generic class `Foo`, this is called\n",
      " |      when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.\n",
      " |\n",
      " |      However, note that this method is also called when defining generic\n",
      " |      classes in the first place with `class Foo[T]: ...`.\n",
      " |\n",
      " |  __init_subclass__(...)\n",
      " |      Function to initialize subclasses.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from openai import OpenAI\n",
    "help(OpenAI)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6769525f-30d9-44e9-900f-4d630de8f035",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
